package com.jprocms.module.cms.dal.mysql.content;

import com.jpro.framework.common.pojo.PageResult;
import com.jpro.framework.mybatis.core.mapper.BaseMapperX;
import com.jpro.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.jprocms.module.cms.controller.admin.content.tagvo.TagExportReqVO;
import com.jprocms.module.cms.controller.admin.content.tagvo.TagPageReqVO;
import com.jprocms.module.cms.dal.dataobject.content.TagDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * tag词 Mapper
 *
 * @author jprocms
 */
@Mapper
public interface TagMapper extends BaseMapperX<TagDO> {

    default PageResult<TagDO> selectPage(TagPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TagDO>()
                .likeIfPresent(TagDO::getTagName, reqVO.getTagName())
                .eqIfPresent(TagDO::getSiteId, reqVO.getSiteId())
                .eqIfPresent(TagDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(TagDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TagDO::getId));
    }

    default List<TagDO> selectList(TagExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TagDO>()
                .likeIfPresent(TagDO::getTagName, reqVO.getTagName())
                .eqIfPresent(TagDO::getSiteId, reqVO.getSiteId())
                .eqIfPresent(TagDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(TagDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TagDO::getId));
    }

}
